﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace UMLDesigner.Widgets
{
    public enum UMLWidgetType
    {
        CLASS,
        NOTE,
        PACKAGE,
        NONE
    }

    public abstract class UMLWidget
    {
        public UMLWidget()
        {
            links = new List<LinkWidget>();
        }

        public virtual bool IsIn(Point point)
        {
            Rectangle rect = new Rectangle(Location, Size);
            return rect.Contains(point);
        }

        public virtual bool IsIn(Rectangle area)
        {
            return area.Contains(new Point(Location.X, Location.Y)) &&
                area.Contains(new Point(Location.X + Size.Width, Location.Y)) &&
                area.Contains(new Point(Location.X, Location.Y + Size.Height)) &&
                area.Contains(new Point(Location.X + Size.Width, Location.Y + Size.Height));
        }

        public virtual Slot AssignSlot(UMLWidget destination)
        {
            return null;
        }

        public virtual void DeleteSlot(Slot slot)
        {

        }

        public abstract void DrawItem(Graphics g);
        public abstract void DrawSelected(Graphics g);
        public abstract void DrawFocused(Graphics g);

        public virtual Point Location
        {
            get;
            set;
        }

        public virtual Size Size
        {
            get;
            set;
        }

        public string Name
        {
            get;
            set;
        }

        public UMLWidgetType Type
        {
            get
            {
                return type;
            }
        }

        public List<LinkWidget> Links
        {
            get
            {
                return links;
            }
        }

        protected UMLWidgetType type;
        protected List<LinkWidget> links;
    }
}
